import "reflect-metadata"
class Test {
    public static clsMethod() { }
    public intMethod() { }
}
const t = new Test()
//写入
Reflect.defineMetadata("meta", '这是类的元数据', Test)

Reflect.defineMetadata('meta', {
    name: "你好"
}, Test, 'clsMethod')

Reflect.defineMetadata('meta', '这也是一个方法', Test, 'intMethod')
//读取
console.log(Reflect.getMetadata('meta', Test), "=====");

console.log(Reflect.getMetadata('meta', Test, 'clsMethod'), "=====方法");

console.log(Reflect.getMetadata('meta', Test, 'intMethod'), "=====继续获取")

//结合装饰器
function classDecorator():ClassDecorator {
    return (target) => {
        Reflect.defineMetadata('meta', "装饰器", target)
    }
}
function staticDecorator():MethodDecorator {
    return (target,key,descriptor:PropertyDescriptor) => {
        Reflect.defineMetadata('meta', "给属性上面添加", target, key)
        return descriptor
    }
}
@classDecorator()
class Test2 {
    @staticDecorator()
    public static myMethod() {}
}

const a = new Test2()
console.log(Reflect.getMetadata('meta', Test2), "===装饰器");
console.log(Reflect.getMetadata('meta',Test2,'myMethod'),'+====给属性上添加')